import request from "@/utils/request";
import { method } from "lodash";

/**
 * 商品分类树
 */
export const getCategoryTree = (search = "") => {
  return request({
    url: `/mall/admin/category/getcategoryList?search=${search}`,
    method: "get"
  });
};

/**
 * 获取商品日志
 */
export const getLog = data => {
  return request({
    url: "/mall/common/product/logs",
    method: "post",
    data
  });
};

/**
 * 获取商品列表
 */
export const getProductList = data => {
  return request({
    url: "/mall/admin/product/page",
    method: "post",
    data
  });
};

/**
 * 批量修改商品分类
 */
export const updateProductCategory = data => {
  return request({
    url: "/mall/admin/product/batchChangeProductCategory",
    method: "post",
    data
  });
};

/**
 * 商品下架
 */
export const soldOut = data => {
  return request({
    url: "/mall/admin/operation/down",
    method: "post",
    data
  });
};

/**
 * 商品上架
 */
export const shelves = data => {
  return request({
    url: "/mall/tenant/factory/product/reListing",
    method: "post",
    data
  });
};
/**
 * 保存运营区域
 */
export const saveArea = data => {
  return request({
    url: "/mall/admin/product/batchSaveOperateArea",
    method: "post",
    data
  });
};

/**
 * 批量修改商品名称
 */
export const batchUpdateName = data => {
  return request({
    url: "/mall/admin/product/batchChangeProductName",
    method: "post",
    data
  });
};

/**
 * 商品审核
 */
export const audit = data => {
  return request({
    url: "/mall/admin/product/audit",
    method: "post",
    data
  });
};

/**
 * 撤销驳回
 */
export const cancelOverrule = productId => {
  return request({
    url: "/mall/admin/product/cancel",
    method: "post",
    data: {
      productId
    }
  });
};

/**
 * 获取数据
 */
export const getCount = data => {
  return request({
    url: "/mall/admin/product/barProductTotal",
    method: "post",
    data
  });
};
/**
 * 获取商品区域设置
 */
export const getGoodsArea = data => {
  return request({
    url: "/mall/admin/product/getOperateAreaList",
    method: "post",
    data
  });
};
/**
 * 单个运营区域修改
 */
export const setArea = data => {
  return request({
    url: "/mall/admin/product/saveOperateArea",
    method: "post",
    data
  });
};
/**
 * 获取地区
 */
export const getArea = keywords => {
  return request({
    url: `/dbo/region/tree/search?keywords=${keywords}`
  });
};

/**
 * 获取平台属性列表
 */
export const getPlatformAttributeList = () => {
  return request({
    url: "/mall/tenant/stasts/getPlatformStastsAndProductNum"
  });
};

/**
 * 查询分类树
 */
export const getCategoryTreeList = search => {
  return request({
    url: `/mall/tenant/category/getcategoryList?search=${search}`
  });
};

/**
 * 平台属性商品列表
 */
export const getPlatformProductList = data => {
  return request({
    url: "/mall/shopStasts/pageAndStasts",
    method: "post",
    data
  });
};

/**
 * 报错or修改平台属性
 */
export const saveEditPlatformAtrr = data => {
  return request({
    url: "/mall/shopStasts/saveSasts",
    method: "post",
    data
  });
};
/**
 * 导出工厂商品统计数据
 */
export const exportFactory = data => {
  return request({
    url: "/mall/admin/product/exportFactoryProductStatistics",
    method: "post",
    data,
    responseType: "blob"
  });
};
